/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package carrello.impl.controller.administrator;

import carrello.impl.controller.AbstractCTRL;
import carrello.model.entities.Company;
import carrello.model.entitydao.CompanyDAO;
import org.hibernate.Session;
import static carrello.util.EntityManagerUtil.getEntityManager;

/**
 *
 * @author Mehdi
 */
public class UpdateCompanyInfoCTRL extends AbstractCTRL{

    public static Company getCompanyInfo() {
        CompanyDAO companyDAO = new CompanyDAO ();
        return companyDAO.getCompany ();        
    }
    
    public boolean updateSystemInfo(String name, String slogan, String url, String email, String phone, String address){
        //Company company = Company.getCompanyByName();
        CompanyDAO companyDAO = new CompanyDAO();
        Company company = companyDAO.getCompany();
        company.setName(name);
        company.setSlogan(slogan);
        company.setUrl(url);
        company.setEmail(email);
        company.setPhone(phone);
        company.setAddress(address);
        init();
        getEntityManager().update(company);
        end();
        return true;
        
    }
    
}
